package com.songlanyun.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonValue;
import com.songlanyun.common.drive.IntegerEnum;

import java.util.Objects;

/**
 * 商品的相关枚举
 */
public class GoodsConstant {
    /**
     * 商品分区特征(0普通商品,1激活区商品)
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum AreaFeature implements IntegerEnum<Integer> {
        //普通商品
        GENERAL(0,"普通商品"),
        ACTIVATING(1, "激活区商品"),
//        Repurchase
        REPURCHASE(2, "复购区商品"),
        EXCHANGING(122, "兑换区商品");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        AreaFeature(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static AreaFeature getByCode(int code) {
            for (AreaFeature value : AreaFeature.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 购买服务礼包可以占有的区域
     * * 0：无
     * * 1：创客
     * * 2：爱心小屋
     * * 3：服务驿站
     * * 4：服务中心
     * * 5：市级
     * * 6：省级公司
     * * 7：大区公司
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum ServicePackageArea implements IntegerEnum<Integer> {
        NOT(0, "无"),
        MAKER(1, "创客"),
        COMMUNITY(2, "爱心小屋"),
        STREET(3, "服务驿站"),
        AREA(4, "服务中心"),
        CITY(5, "市级"),
        PROVINCE(6, "省级公司"),
        MUL_PROVINCE(7, "大区公司"),
        ;


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        ServicePackageArea(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        @Override
        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ServicePackageArea getByCode(int code) {
            for (ServicePackageArea value : ServicePackageArea.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 审核状态
     */
    @JsonFormat(shape = JsonFormat.Shape.OBJECT)
    public static enum VerifyStatus implements IntegerEnum<Integer> {
        WAIT(0, "待审核"),
        YES(1, "通过"),
        NO(2, "不通过");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        VerifyStatus(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static VerifyStatus getByCode(int code) {
            for (VerifyStatus value : VerifyStatus.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 单品入库类型
     */
    public static enum InStockType implements IntegerEnum<Integer> {
        //入库类型(0，1初始化库存，2手动入库，3维权入库，4撤单入库，5，支付过期入库，6自提过期，7支付成功,条件不允许,自动退款关闭
        EMPTY(0, ""),
        INIT(1, "初始化库存"),
        MANUAL(2, "手动入库"),
        RETURN_GOODS(3, "维权入库"),
        CANCEL_ORDER(4, "撤单入库"),
        PAY_EXPIRE(5, "支付过期入库"),
        PICKUP_EXPIRE(6, "自提过期"),
        PAY_SUCCESS_CONDITION_REFUND(7, "支付成功,条件不允许,自动退款关闭"),
        OTHER(8, "其它方式入库");

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        InStockType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static InStockType getByCode(int code) {
            for (InStockType value : InStockType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 单品出库类型
     */
    public static enum OuterStockType implements IntegerEnum<Integer> {
        //0空，1下单出库，2手单出库
        EMPTY(0, ""),
        ORDER(1, "下单出库"),
        MANUAL(2, "手动出库");


        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        OuterStockType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static OuterStockType getByCode(int code) {
            for (OuterStockType value : OuterStockType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 出入库的模式（0入，1出）
     */
    public enum StockChangeMode implements IntegerEnum<Integer> {
        IN(0, "入库"),
        OUT(1, "出库");

        StockChangeMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;


        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static StockChangeMode getByCode(int code) {
            for (StockChangeMode value : StockChangeMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 0非礼包，1.礼包282，2.礼包6750
     */
    public enum GiftType implements IntegerEnum<Integer> {
        NO(0, "非礼包"),
        礼包282(1, "礼包282"),
        礼包6750(2, "礼包6750"),
        COMMON(3, "普通代销");


        GiftType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;


        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static GiftType getByCode(int code) {
            for (GiftType value : GiftType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }

    /**
     * 计算模式，0固定价格，1固定比例
     */
    public enum ComputeMode implements IntegerEnum<Integer> {
        FIXED_PRICE(0, "固定价格"),
        FIXED_RATIO(1, "固定比例");

        ComputeMode(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;


        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static ComputeMode getByCode(int code) {
            for (ComputeMode value : ComputeMode.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


    /**
     * 商品类型
     * 0：普通商品
     * 1：服务商品
     * 2：活动商品
     * 3：积分商品
     * 4：充值商品
     */
    public static enum GoodsType implements IntegerEnum<Integer> {
        GENERAL_GOODS(0, "普通商品"),
        SERVICE_GOODS(1, "服务商品"),
        ACTIVITY_GOODS(2, "活动商品"),
        INTEGRAL_GOODS(3, "积分商品"),
        REFILL_GOODS(4, "转入商品"),//充值卡

        ;
        @EnumValue
        @JsonValue
        private Integer code;

        private String msg;

        GoodsType(Integer code, String msg) {
            this.code = code;
            this.msg = msg;
        }

        public void setCode(Integer code) {
            this.code = code;
        }

        public String getMsg() {
            return msg;
        }

        public void setMsg(String msg) {
            this.msg = msg;
        }

        @Override
        public Integer getCode() {
            return code;
        }

        @JsonCreator
        public static GoodsType getByCode(int code) {
            for (GoodsType value : GoodsType.values()) {
                if (Objects.equals(code, value.getCode())) {
                    return value;
                }
            }
            return null;
        }
    }


/**
 * 其它和商品相关的状态或枚举继续定往下定义
 */
}
